package c.test;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

public class Demo {

    public static void main(String[] args) {
        // System.out.println("豌豆荚连接服务".length());
//        System.out.println(getManufacturer(""));


        String s = "[gsm.network.type]: [UMTS]\r\n" + "[gsm.operator.alpha]: [Android]\r\n"
                + "[gsm.operator.iso-country]: [us]\r\n" + "[gsm.operator.isroaming]: [false]\r\n"
                + "[gsm.operator.numeric]: [310260]\r\n" + "[gsm.sim.operator.iso-country]: [us]\r\n"
                + "[gsm.sim.operator.alpha]: [Android]\r\n";
        System.out.println(s);
        System.err.println(s.replace("[", "").replace("]",""));
    }

    private static String url = "http://api.macvendors.com/";

    /**
     * 根据Mac获取厂商
     *
     * @param mac
     * @return
     */
    public static String getManufacturer(String mac) {
        try {
            Document doc = Jsoup.connect(url).header("Accept-Language", "zh-CN,zh;q=0.8")
                    .header("Accept-Encoding", "gzip, deflate, sdch")
                    .userAgent(
                            "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.75 Safari/537.36")
                    .timeout(3 * 1000).ignoreContentType(true).ignoreHttpErrors(true).data("mac", "60:d9:a0:da:f8:e7")
                    .post();
            return doc.text();
        } catch (Throwable e) {
            return "";
        }
    }

}
